public class PrototypePattern {
    public static void main(String[] args) {
        Resume resume1 = new Resume();
        resume1.setAge("11");
        resume1.setName("hi");
        resume1.setWorkExperience(new WorkExperience().setCorporationName("Mozyun"));
        System.out.println(resume1.toString());
        Resume resume2 = null;
        try {
            resume2 = resume1.clone();
        } catch (CloneNotSupportedException e) {
        }
        if (resume1 != null) {
            // resume2.setWorkExperience(new WorkExperience().setCorporationName("Ali"));
            // System.out.println(resume1.toString());
            resume2.getWorkExperience().setCorporationName("Ali");
            System.out.println(resume1.toString());
        }

    }
}

class Resume implements Cloneable {
    String name;
    String age;
    WorkExperience workExperience;

    @Override
    public String toString() {
        return "Resume [name=" + name + ", age=" + age + ", workExperience=" + workExperience + "]";
    }

    @Override
    protected Resume clone() throws CloneNotSupportedException {

        Resume ori= (Resume) super.clone();
        ori.setWorkExperience(workExperience.clone());
        return ori;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }

    public WorkExperience getWorkExperience() {
        return workExperience;
    }

    public Resume setWorkExperience(WorkExperience workExperience) {
        this.workExperience = workExperience;
        return this;
    }
}

class WorkExperience implements Cloneable {
    String corporationName;

    @Override
    protected WorkExperience clone() throws CloneNotSupportedException {
        return (WorkExperience)super.clone();
    }

    @Override
    public String toString() {
        return "WorkExperience [corporationName=" + corporationName + "]";
    }

    public String getCorporationName() {
        return corporationName;
    }

    public WorkExperience setCorporationName(String corporationName) {
        this.corporationName = corporationName;
        return this;
    }

}